using System;

namespace RFS.Domain.PaiShi
{
    
    
 
    public class OrderItem :   IOrderItem
    {
        public OrderItem(long localId, string bizId, int quantity, dynamic rawData, DateTime bizTime, string bizIdMapingName, decimal amount, bool isChecked, IProduct product, bool recordedInAcc, BizFlowNodeEnum ordType)
        {
            LocalId = localId;
            BizId = bizId;
            Quantity = quantity;
            RawData = rawData;
            BizTime = bizTime;
            BizIdMapingName = bizIdMapingName;
            Amount = amount;
            IsChecked = isChecked;
            Product = product;
            RecordedInAcc = recordedInAcc;
            OrdType = ordType;
        }

        public OrderItem()
        {
        }

        public long LocalId { get; set; }
        public string BizId { get; set; }
        public int Quantity { get; set; }
        
  
        public dynamic RawData { get; set; }
        public DateTime BizTime { get; set; }
        public string BizIdMapingName { get; set; }
        public decimal Amount { get; set; }
        public bool IsChecked { get ; set; }
        public IProduct Product { get; set; }
        public string Key { get=>$"{BizTime:yyyyMMdd}/{Product?.Key}/{Quantity}"; }
        public bool RecordedInAcc { get; set; }
        public BizFlowNodeEnum OrdType { get; set; }


        public override bool Equals(object obj)
        {
            var a = this as OrderItem;
            var b = obj as OrderItem;
             
                // id+suplier+quantity+
                if (a == null || b == null) return false;
                return $"{a.BizId}{a.Product.Key}{a.Quantity}"== $"{b.BizId}{b.Product.Key}{b.Quantity}";
             

        }
    }
}